<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<%

    String url = "jdbc:mysql://localhost:3306/carxianyu?useSSL=false";
    String user = "root";
    String pwd = "root";

    Integer userid = Integer.valueOf(session.getAttribute("id").toString());

    String sql = "  SELECT *   from car a  WHERE   a.id in( select carid  from collection c where c.userid = "+userid+" ORDER BY createtime desc )  ";

    //jdbc 连接数据库
    Class.forName("com.mysql.jdbc.Driver");//加载驱动
    Connection conn = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    PreparedStatement a = conn.prepareStatement(sql);
    ResultSet rs = a.executeQuery();
    System.out.println("执行了sql =====》"+sql);
%>

<head>
    <meta charset="utf-8">
    <title>二手汽车平台——我的收藏</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/template.css" media="all">
    <script src="${ctx}/static/layui/layui.js"></script>
</head>
<body>
<!--导航条 start-->
<jsp:include page="/head.jsp"/>

<!--导航条 end-->

<!--轮播图 start-->
<jsp:include page="/banner.jsp"/>
<!--轮播图 end-->
<div class="layui-fluid">


    <table class="layui-table">
        <tbody>
        <tr class="layui-bg-blue">
            <th>车名</th>
            <th>车价</th>
            <th>车主</th>
            <th>联系电话</th>
            <th>引擎</th>
            <th>收藏人数</th>
            <th>操作</th>
        </tr>
        <% while(rs.next()){

            //为列表参数初始化

            String number  = rs.getString("number");
            Integer id = rs.getInt("id");
            String username = rs.getString("username");
            String name = rs.getString("name");
            String images = rs.getString("images");
            String price = rs.getString("price");
            String introduction = rs.getString("introduction");
            String address = rs.getString("address");
            Integer age =Integer.valueOf( rs.getString("age"));
            String createtime = rs.getString("createtime");
            String identity = rs.getString("identity");
            String phone = rs.getString("phone");
            Integer collection =Integer.valueOf( rs.getString("collection"));
            Integer gearboxId =Integer.valueOf( rs.getString("gearbox"));
            Integer statusid = Integer.valueOf( rs.getString("status"));

            String status = null;

            Boolean isShenhe = false;
            if(statusid == 11){
                isShenhe = true;
                status = "待审核";
            }else if(statusid == 22){
                isShenhe = false;
                status = "审核通过";
            }else {
                isShenhe = true;
                status = "审核拒绝";
            }


            String gearbox = null;
            if(gearboxId == 11){
                gearbox = "手动档";
            }else {
                gearbox= "自动档";
            }
            //3 取消收藏
            String deleteUri =  "/view/customer/customer/collection/doCollectionExcute.jsp?state=3&carid="+id;

        %>


        <tr>
            <td><%=name%></td>
            <td><%=price%></td>
            <td><%=username%></td>
            <td><%=phone%></td>
            <td><%=gearbox%></td>
            <td><%=collection%></td>
            <td style="width: 180px;">
                <a href="${ctx}<%=deleteUri%>" class="layui-btn layui-btn-danger layui-btn-sm">取消收藏</a>
            </td>
        </tr>

        <%}%>

        </tbody>
    </table>


</div>






<style>
    .comment {
        margin-top: 4%;
        margin-left: 14%;
        padding: 2%;
        width: 68%;
        background-color: #ececec;
        border: 1px dashed #888;
        border-radius: 1em;
        position: relative;
        display: block;
        text-align: left;
    }

    .comment:hover img {
        border-radius: 1em;
        border: 2px solid #888;
    }

    .comment:hover {
        background-color: #eee;
    }

    .comment img {
        position: absolute;
        top: -1%;
        left: -10%;
        border-radius: 2em;
        border: 2px solid #888;
        width: 60px;
        height: 60px;
    }

    .comment p {
        text-indent: 2em;
        margin-top: 0.4%;
    }

    .comment span {
        position: absolute;
        top: 10%;
        right: 4%;
        font-size: 0.9em;
        font-weight: bold;
        color: #444
    }

    .comment .name {
        color: black;
        font-weight: bold;
        text-decoration: none;
    }

    .comment .name:hover {
        text-decoration: underline;
    }

    .comment .up {
        color: #555;
        text-decoration: none;
        position: absolute;
        bottom: 4%;
        right: 8%;
    }

    .comment .up:hover {
        color: #000;
    }
</style>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;

        //…
    });
</script>
</body>
</html>
